/*
 * main.h
 *
 *  Created on: 28.11.2011
 *      Author: alexs
 */

#ifndef MAIN_H_
#define MAIN_H_
#include <errno.h>
#include <sys/stat.h>
#include <sys/times.h>
#include <sys/unistd.h>
#include <stm32f10x.h>
#include "stm32f10x_conf.h"

// errno
#undef errno
extern int errno;

#define USART_TX_BUFF_SIZE 128
#define USART2TXDMA DMA1_Channel7
#define USART2TCFLAG DMA1_FLAG_TC7
#define NIRQ_stat() GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0)

#define CHIP26_2 0x066FFF51
#define CHIP26_1 0x50546649
#define CHIP26_0 0x87172627

#define CHIP27_2 0x0668FF51
#define CHIP27_1 0x50546649
#define CHIP27_0 0x87172727

typedef enum {READ=0,WRITE} SPI_dir;

extern char USART_TX_BUFF[USART_TX_BUFF_SIZE];

#define POINTS_SIZE 16 /* 4 x 32bit */
#define HEADER_SIZE 5
#define NUM_POINTS 3

typedef struct{
	uint8_t point_name;
	uint8_t total_points;
	uint8_t current_point;
	uint8_t reserved2;
	uint32_t point_time;
	uint32_t point_lat;
	uint32_t point_lon;
} point_t;

#endif /* MAIN_H_ */
